package com.example.tool.db;

import java.util.HashMap;
import java.util.Map;

public class SqlExec {
  private final Map<String, String> sqlMap = new HashMap<>();

  public SqlExec() {
  }

  public SqlExec(String sql) {
    sqlMap.put("sql*", sql);
  }

  public SqlExec sqlserver(String sql) {
    sqlMap.put("SQLSERVER", sql);
    return this;
  }

  public SqlExec mysql(String sql) {
    sqlMap.put("MYSQL", sql);
    return this;
  }

  public SqlExec oracle(String sql) {
    sqlMap.put("ORACLE", sql);
    return this;
  }

  public SqlExec addSql(String sqlType, String sql) {
    sqlMap.put(sqlType, sql);
    return this;
  }

  public String getSql(String sqlType) {
    String sql = sqlMap.get(sqlType);
    if (sql == null && !sqlType.equals("sql*")) {
      sql = sqlMap.get("sql*");
    }
    return sql;
  }
}
